package org.example.juc.p11;

import lombok.extern.slf4j.Slf4j;

import java.sql.SQLOutput;

/**
 * @author lou ke
 * @since 2024/2/10 20:10
 */
@Slf4j
public class YieldThread {

    public static void main(String[] args) {

        class Task1 implements Runnable {

            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    log.info("A" + i);
                }

            }
        }


        class Task2 implements Runnable {

            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    // Thread.yield();
                    log.info("B" + i);
                }

            }
        }


        Thread thread1= new Thread(new Task2());
        thread1.setPriority(Thread.MAX_PRIORITY);
        thread1.start();


        Thread thread2 = new Thread(new Task1());
        thread2.setPriority(Thread.MIN_PRIORITY);
        thread2.start();
    }


}
